package com.user.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @Author : Yu
 * @Date 2023/6/14 14:32
 */

@Configuration
@EnableTransactionManagement
@MapperScan("com.user.mapper")
public class MybatisConfig {
    @Bean
    public MybatisPlusInterceptor paginationInterceptor() {
        PaginationInnerInterceptor page = new PaginationInnerInterceptor(DbType.MYSQL);
        //溢出总页数后是否做处理（默认不做，true表示做处理，回到首页） false  继续请求
        page.setOverflow(false);
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //设置数据库类型为mysql
        interceptor.addInnerInterceptor(page);
        return interceptor;

    }
}
